]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
ShellGlobal: remove cursor manipulation functions
authorGiovanni Campagna <gcampagn@redhat.com>
Wed, 11 Sep 2013 15:35:58 +0000 (17:35 +0200)
committerGiovanni Campagna <gcampagn@redhat.com>
Thu, 12 Sep 2013 08:34:22 +0000 (10:34 +0200)
Use the new API in MetaScreen instead, which is automatically
routed to MetaCursorTracker as appropriate.

https://bugzilla.gnome.org/show_bug.cgi?id=707467

js/ui/dnd.js
js/ui/messageTray.js
js/ui/screenshot.js
src/shell-global.c
src/shell-global.h

index 6752eb32d42c05dc9ae13c046e44f2a3fc822fcb..b1d2e679e856823ba1fc0eafbec5f24b35b2b9ee 100644 (file)
@@ -5,6 +5,7 @@ const GLib = imports.gi.GLib;
 const Gtk = imports.gi.Gtk;
 const St = imports.gi.St;
 const Lang = imports.lang;
+const Meta = imports.gi.Meta;
 const Shell = imports.gi.Shell;
 const Signals = imports.signals;
 const Tweener = imports.ui.tweener;
@@ -27,9 +28,9 @@ const DragMotionResult = {
 };
 
 const DRAG_CURSOR_MAP = {
-    0: Shell.Cursor.DND_UNSUPPORTED_TARGET,
-    1: Shell.Cursor.DND_COPY,
-    2: Shell.Cursor.DND_MOVE
+    0: Meta.Cursor.DND_UNSUPPORTED_TARGET,
+    1: Meta.Cursor.DND_COPY,
+    2: Meta.Cursor.DND_MOVE
 };
 
 const DragDropResult = {
@@ -244,7 +245,7 @@ const _Draggable = new Lang.Class({
         if (this._onEventId)
             this._ungrabActor();
         this._grabEvents();
-        global.set_cursor(Shell.Cursor.DND_IN_DRAG);
+        global.screen.set_cursor(Meta.Cursor.DND_IN_DRAG);
 
         this._dragX = this._dragStartX = stageX;
         this._dragY = this._dragStartY = stageY;
@@ -374,7 +375,7 @@ const _Draggable = new Lang.Class({
             if (motionFunc) {
                 let result = motionFunc(dragEvent);
                 if (result != DragMotionResult.CONTINUE) {
-                    global.set_cursor(DRAG_CURSOR_MAP[result]);
+                    global.screen.set_cursor(DRAG_CURSOR_MAP[result]);
                     return false;
                 }
             }
@@ -392,13 +393,13 @@ const _Draggable = new Lang.Class({
                                                              targY,
                                                              0);
                 if (result != DragMotionResult.CONTINUE) {
-                    global.set_cursor(DRAG_CURSOR_MAP[result]);
+                    global.screen.set_cursor(DRAG_CURSOR_MAP[result]);
                     return false;
                 }
             }
             target = target.get_parent();
         }
-        global.set_cursor(Shell.Cursor.DND_IN_DRAG);
+        global.screen.set_cursor(Meta.Cursor.DND_IN_DRAG);
         return false;
     },
 
@@ -470,7 +471,7 @@ const _Draggable = new Lang.Class({
                     }
 
                     this._dragInProgress = false;
-                    global.unset_cursor();
+                    global.screen.set_cursor(Meta.Cursor.DEFAULT);
                     this.emit('drag-end', event.get_time(), true);
                     this._dragComplete();
                     return true;
@@ -522,7 +523,7 @@ const _Draggable = new Lang.Class({
         let [snapBackX, snapBackY, snapBackScale] = this._getRestoreLocation();
 
         if (this._actorDestroyed) {
-            global.unset_cursor();
+            global.screen.set_cursor(Meta.Cursor.DEFAULT);
             if (!this._buttonDown)
                 this._dragComplete();
             this.emit('drag-end', eventTime, false);
@@ -576,7 +577,7 @@ const _Draggable = new Lang.Class({
         } else {
             dragActor.destroy();
         }
-        global.unset_cursor();
+        global.screen.set_cursor(Meta.Cursor.DEFAULT);
         this.emit('drag-end', eventTime, false);
 
         this._animationInProgress = false;
index 69a822dea8db8d475e0f5963e406853652a44662..bc9136eb779906466fbf5aab7a8744715b2308d5 100644 (file)
@@ -215,10 +215,10 @@ const URLHighlighter = new Lang.Class({
 
             let urlId = this._findUrlAtPos(event);
             if (urlId != -1 && !this._cursorChanged) {
-                global.set_cursor(Shell.Cursor.POINTING_HAND);
+                global.screen.set_cursor(Meta.Cursor.POINTING_HAND);
                 this._cursorChanged = true;
             } else if (urlId == -1) {
-                global.unset_cursor();
+                global.screen.set_cursor(Meta.Cursor.DEFAULT);
                 this._cursorChanged = false;
             }
             return false;
@@ -229,7 +229,7 @@ const URLHighlighter = new Lang.Class({
 
             if (this._cursorChanged) {
                 this._cursorChanged = false;
-                global.unset_cursor();
+                global.screen.set_cursor(Meta.Cursor.DEFAULT);
             }
         }));
     },
index 2219a890f5e717ef194edee6826300fdc26edcc4..92efd03b4575b380aee63820d8474a228959deb3 100644 (file)
@@ -6,6 +6,7 @@ const Gio = imports.gi.Gio;
 const GLib = imports.gi.GLib;
 const Gtk = imports.gi.Gtk;
 const Lang = imports.lang;
+const Meta = imports.gi.Meta;
 const Shell = imports.gi.Shell;
 const Signals = imports.signals;
 const St = imports.gi.St;
@@ -167,7 +168,7 @@ const SelectArea = new Lang.Class({
         if (!Main.pushModal(this._group) || this._group.visible)
             return;
 
-        global.set_cursor(Shell.Cursor.CROSSHAIR);
+        global.screen.set_cursor(Meta.Cursor.CROSSHAIR);
         this._group.visible = true;
     },
 
@@ -238,7 +239,7 @@ const SelectArea = new Lang.Class({
                                function() {
                                    Main.popModal(this._group);
                                    this._group.destroy();
-                                   global.unset_cursor();
+                                   global.screen.set_cursor(Meta.Cursor.DEFAULT);
 
                                    this.emit('finished', geometry);
                                })
index 0ea3287b3a08479459e285f7888dc245ec592ac1..1d0dadc1be79ccb089533629fe00c5a96465884a 100644 (file)
@@ -27,6 +27,7 @@
 #include <meta/display.h>
 #include <meta/util.h>
 #include <meta/meta-shaped-texture.h>
+#include <meta/meta-cursor-tracker.h>
 
 /* Memory report bits */
 #ifdef HAVE_MALLINFO
@@ -599,91 +600,6 @@ sync_input_region (ShellGlobal *global)
     meta_set_stage_input_region (screen, global->input_region);
 }
 
-/**
- * shell_global_set_cursor:
- * @global: A #ShellGlobal
- * @type: the type of the cursor
- *
- * Set the cursor on the stage window.
- */
-void
-shell_global_set_cursor (ShellGlobal *global,
-                         ShellCursor type)
-{
-  const char *name;
-  GdkCursor *cursor;
-
-  switch (type)
-    {
-    case SHELL_CURSOR_DND_IN_DRAG:
-      name = "dnd-none";
-      break;
-    case SHELL_CURSOR_DND_MOVE:
-      name = "dnd-move";
-      break;
-    case SHELL_CURSOR_DND_COPY:
-      name = "dnd-copy";
-      break;
-    case SHELL_CURSOR_DND_UNSUPPORTED_TARGET:
-      name = "dnd-none";
-      break;
-    case SHELL_CURSOR_POINTING_HAND:
-      name = "hand";
-      break;
-    case SHELL_CURSOR_CROSSHAIR:
-      name = "crosshair";
-      break;
-    default:
-      g_return_if_reached ();
-    }
-
-  cursor = gdk_cursor_new_from_name (global->gdk_display, name);
-  if (!cursor)
-    {
-      GdkCursorType cursor_type;
-      switch (type)
-        {
-        case SHELL_CURSOR_DND_IN_DRAG:
-          cursor_type = GDK_FLEUR;
-          break;
-        case SHELL_CURSOR_DND_MOVE:
-          cursor_type = GDK_TARGET;
-          break;
-        case SHELL_CURSOR_DND_COPY:
-          cursor_type = GDK_PLUS;
-          break;
-        case SHELL_CURSOR_POINTING_HAND:
-          cursor_type = GDK_HAND2;
-          break;
-        case SHELL_CURSOR_CROSSHAIR:
-          cursor_type = GDK_CROSSHAIR;
-          break;
-        case SHELL_CURSOR_DND_UNSUPPORTED_TARGET:
-          cursor_type = GDK_X_CURSOR;
-          break;
-        default:
-          g_return_if_reached ();
-        }
-      cursor = gdk_cursor_new (cursor_type);
-    }
-
-  gdk_window_set_cursor (global->stage_gdk_window, cursor);
-
-  g_object_unref (cursor);
-}
-
-/**
- * shell_global_unset_cursor:
- * @global: A #ShellGlobal
- *
- * Unset the cursor on the stage window.
- */
-void
-shell_global_unset_cursor (ShellGlobal  *global)
-{
-  gdk_window_set_cursor (global->stage_gdk_window, NULL);
-}
-
 /**
  * shell_global_set_stage_input_region:
  * @global: the #ShellGlobal
index 0e11cc7f3c9e9da1a6fdb047249d7b8413922f7b..037b55f6f62baf30d2d82397e20cc1a47190506e 100644 (file)
@@ -50,20 +50,6 @@ void     shell_global_freeze_keyboard        (ShellGlobal         *global,
 void     shell_global_set_stage_input_region (ShellGlobal         *global,
                                               GSList              *rectangles);
 
-/* X utilities */
-typedef enum {
-  SHELL_CURSOR_DND_IN_DRAG,
-  SHELL_CURSOR_DND_UNSUPPORTED_TARGET,
-  SHELL_CURSOR_DND_MOVE,
-  SHELL_CURSOR_DND_COPY,
-  SHELL_CURSOR_POINTING_HAND,
-  SHELL_CURSOR_CROSSHAIR
-} ShellCursor;
-
-void    shell_global_set_cursor              (ShellGlobal         *global,
-                                              ShellCursor          type);
-void    shell_global_unset_cursor            (ShellGlobal         *global);
-
 void    shell_global_get_pointer             (ShellGlobal         *global,
                                               int                 *x,
                                               int                 *y,